
/*app所用所有ajax*/

(function($,owner){

//var urlPublic = "http://115.28.246.2/meilidaluandou/php/"; 
var urlPublic = "http://192.168.1.130/myweb/meilidaluandou/php/"; //测试用
 
/* 注册*/
 owner.reg = function(regInfo,callback){
     callback = callback || $.noop;
     regInfo = regInfo || {};
     
     $.ajax(urlPublic+'reg.php',{
        data:regInfo, 
        dataType:'json',
        type:'post',
        timeout:10000,//超时时间设置为10秒；
        // headers:{'Content-Type':'application/json'},                   
        success:function(data){  
            return callback(data);
        },
        error:function(xhr,type,errorThrown){   
            //异常处理； 
            return callback("注册失败！");
        }
    });  
 };
 
 
 /* 登录*/
 owner.login = function(loginInfo,callback){
     callback = callback || $.noop;
     loginInfo = loginInfo || {};
     
     $.ajax(urlPublic+'login.php',{
        data:loginInfo, 
        dataType:'json',
        type:'post',
        timeout:10000,//超时时间设置为10秒；
        // headers:{'Content-Type':'application/json'},                   
        success:function(data){  
            callback(data);
        },
        error:function(xhr,type,errorThrown){   
            //异常处理； 
            callback("愁人啊！\n不知道哪儿错了，就是登陆不了！");
        }
    });  
 };
 
 
 /*加载个人上传的所有图片*/
owner.getMyImages = function(myinfo,callback){
    callback = callback || $.noop;
    myinfo = myinfo || {};
    
    $.ajax(urlPublic+'getmyimages.php',{
        data:myinfo, 
        dataType:'json',
        type:'post',
        timeout:10000,//超时时间设置为10秒；
        // headers:{'Content-Type':'application/json'},                   
        success:function(data){  
            callback(data);
        },
        error:function(xhr,type,errorThrown){   
            //异常处理； 
            callback("愁人啊！\n不知道哪儿错了，就是找不到图片！");
        }
    });  
};

/*删除图片*/
owner.deleteImg = function(imginfo,callback){
    callback = callback || $.noop;
    imginfo = imginfo || {};
    
    $.ajax(urlPublic+'deleteimg.php',{
        data:imginfo, 
        dataType:'json',
        type:'post',
        timeout:10000,//超时时间设置为10秒；
        // headers:{'Content-Type':'application/json'},                   
        success:function(data){  
            callback(data);
        },
        error:function(xhr,type,errorThrown){   
            //异常处理； 
            callback("愁人啊！\n不知道哪儿错了，删除不了！");
        }
    });  
};


/*上传图片*/
owner.uploadimg = function(imginfo,callback){
    callback = callback || $.noop;
    imginfo = imginfo || {};
    
    jQuery.ajax({  
        url:urlPublic+'uploadimg.php',
        data:imginfo, 
        dataType:'json',
        type:'post',
        processData: false,  
        contentType: false, 
        timeout:100000,              
        success:function(data){ 
            callback(data);   
        },
        error:function(xhr,textStatus){   
            //异常处理； 
            alert("愁人啊！\n 怎么就传不上去呢!? \n我要投诉程序猿！");
            return;
        }
    }); 
};


/*上传喜欢的图品和不喜欢的图片id*/
owner.uploadlikeANDunlike = function(likeinfo,callback){
    callback = callback || $.noop;
    likeinfo = likeinfo || {};
    
    $.ajax(urlPublic+'upload_likenum.php',{
        data:likeinfo, 
        dataType:'json',
        type:'post',
        timeout:10000,//超时时间设置为10秒；
        // headers:{'Content-Type':'application/json'},                   
        success:function(data){  
            callback(data);
        },
        error:function(xhr,type,errorThrown){   
            //异常处理； 
            callback("喜欢和不喜欢的图片没有传到数据库啊！");
        }
    });  
};


/*获取所有的图片信息*/
owner.getallimginfo = function(datainfo,callback){
    callback = callback || $.noop;
    datainfo = datainfo || {};
    
    $.ajax(urlPublic+'getallinfo.php',{
        data:datainfo, 
        dataType:'json',
        type:'post',
        timeout:10000,//超时时间设置为10秒；
        // headers:{'Content-Type':'application/json'},                   
        success:function(data){  
            callback(data);
        },
        error:function(xhr,type,errorThrown){   
            //异常处理； 
            callback("程序员不小心啊，竟然加载不出图片！");
        }
    });  
};


/*获取乱斗图片信息*/
owner.getluandouinfo = function(luandouinfo,callback){
    callback = callback || $.noop;
    datainfo = luandouinfo || {};
    
    $.ajax(urlPublic+'luandou_getinfo.php',{
        data:datainfo, 
        dataType:'json',
        type:'post',
        timeout:10000,//超时时间设置为10秒；
        // headers:{'Content-Type':'application/json'},                   
        success:function(data){  
            callback(data);
        },
        error:function(xhr,type,errorThrown){   
            //异常处理； 
            callback("程序员不小心啊，竟然加载不出图片！");
        }
    });  
};

 
}(mui, window.myajax = {}));

























